package 笔试2.美团.two;

import java.util.Scanner;

import static MyUtils.MHUtils.can;
import static MyUtils.MHUtils.r;

/*
2
2 1 10
1 2
4 3 37
1 1 2 3
 */

//--把‘每样一个凑和’当成工具 用汉语一推【题目：立方和 每样一个 凑37 有次数限制】
public class Main {

    static int[] p;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T =sc.nextInt();
        for (int t = 0; t < T; t++) {
            int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
            int tS=c,hav=b,N=a;
            p = new int[N];
            for (int i = 0; i < N; i++) {
                p[i]=sc.nextInt();
            }
            int minge = minGS(tS, 0);
            int yige= getOne(p);
            if(minge-yige<=hav){
                System.out.println("YES");
            }
            else System.out.println("NO");
        }
    }

    private static int getOne(int[] p) {
        int sum=0;
        for (int i = 0; i < p.length; i++) {
            if(p[i]==1)sum++;
        }
        return sum;
    }

    //最少币个
    private static int minGS(int tS, int ci) {
        can("tS:"+tS+","+"ci:"+ci);
        if(ci==p.length){
            if(tS==0){
                r("0");
                return 0;//最少币数r0
            }
            r("9999");
            return 9999;
        }
        int lifang = (int)Math.pow(p[ci],3);
        r(Math.min(
                minGS(tS-lifang,ci+1) +1,
                minGS(tS,ci+1)
        )+"");
        return Math.min(
                minGS(tS-lifang,ci+1) +1,
                minGS(tS,ci+1)
        );
    }
}
